home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 97 / CD-ROM 97 / CD-ROM 97.iso / internet / ghostzilla / ghsetup.exe / chrome / pippki.jar / content / pippki / deletecert.js < prev    next >
Encoding:
Text File  |  2002-04-09  |  3.6 KB  |  119 lines

  1. /*
  2.  * The contents of this file are subject to the Mozilla Public
  3.  * License Version 1.1 (the "License"); you may not use this file
  4.  * except in compliance with the License. You may obtain a copy of
  5.  * the License at http://www.mozilla.org/MPL/
  6.  *
  7.  * Software distributed under the License is distributed on an "AS
  8.  * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  9.  * implied. See the License for the specific language governing
  10.  * rights and limitations under the License.
  11.  *
  12.  * The Original Code is mozilla.org code.
  13.  *
  14.  * The Initial Developer of the Original Code is Netscape
  15.  * Communications Corporation.  Portions created by Netscape are
  16.  * Copyright (C) 2001 Netscape Communications Corporation. All
  17.  * Rights Reserved.
  18.  *
  19.  * Contributor(s):
  20.  *  Ian McGreer <mcgreer@netscape.com>
  21.  */
  22.  
  23. const nsIX509Cert = Components.interfaces.nsIX509Cert;
  24. const nsX509CertDB = "@mozilla.org/security/x509certdb;1";
  25. const nsIX509CertDB = Components.interfaces.nsIX509CertDB;
  26. const nsIPKIParamBlock = Components.interfaces.nsIPKIParamBlock;
  27. const nsIDialogParamBlock = Components.interfaces.nsIDialogParamBlock;
  28.  
  29. var certdb;
  30. var certs = [];
  31. var helpUrl;
  32.  
  33. function setWindowName()
  34. {
  35.   var params = window.arguments[0].QueryInterface(nsIDialogParamBlock);
  36.   
  37.   //  Get the cert from the cert database
  38.   certdb = Components.classes[nsX509CertDB].getService(nsIX509CertDB);
  39.   
  40.   var typeFlag = params.GetString(0);
  41.   var numberOfCerts = params.GetInt(0);
  42.   var dbkey;
  43.   for(var x=0; x<numberOfCerts;x++)
  44.   {
  45.      dbkey = params.GetString(x+1);
  46.      certs[x] = certdb.getCertByDBKey(dbkey , null);
  47.   }
  48.   
  49.   var bundle = srGetStrBundle("chrome://pippki/locale/pippki.properties");
  50.   var title;
  51.   var confirm;
  52.   var impact;
  53.   
  54.   if(typeFlag == bundle.GetStringFromName("deleteUserCertFlag"))
  55.   {
  56.      title = bundle.GetStringFromName("deleteUserCertTitle");
  57.      confirm = bundle.GetStringFromName("deleteUserCertConfirm");
  58.      impact = bundle.GetStringFromName("deleteUserCertImpact");
  59.      helpUrl = "delete_my_certs"
  60.   }
  61.   else if(typeFlag == bundle.GetStringFromName("deleteSslCertFlag"))
  62.   {
  63.      title = bundle.GetStringFromName("deleteSslCertTitle");
  64.      confirm = bundle.GetStringFromName("deleteSslCertConfirm");
  65.      impact = bundle.GetStringFromName("deleteSslCertImpact");
  66.      helpUrl = "delete_web_certs"
  67.   }
  68.   else if(typeFlag == bundle.GetStringFromName("deleteCaCertFlag"))
  69.   {
  70.      title = bundle.GetStringFromName("deleteCaCertTitle");
  71.      confirm = bundle.GetStringFromName("deleteCaCertConfirm");
  72.      impact = bundle.GetStringFromName("deleteCaCertImpact");
  73.      helpUrl = "delete_ca_certs"   
  74.   }
  75.   else if(typeFlag == bundle.GetStringFromName("deleteEmailCertFlag"))
  76.   {
  77.      title = bundle.GetStringFromName("deleteEmailCertTitle");
  78.      confirm = bundle.GetStringFromName("deleteEmailCertConfirm");
  79.      impact = bundle.GetStringFromName("deleteEmailCertImpact");
  80.      helpUrl = "delete_email_certs"
  81.   }
  82.   else
  83.   {
  84.      return;
  85.   }
  86.   var windowReference = document.getElementById('deleteCertificate');
  87.   var confirReference = document.getElementById('confirm');
  88.   var impactReference = document.getElementById('impact');
  89.   windowReference.setAttribute("title", title);
  90.   
  91.   setText("confirm",confirm);
  92.  
  93.   var box=document.getElementById("certlist");
  94.   var text;
  95.   for(x=0;x<certs.length;x++)
  96.   {
  97.     text = document.createElement("text");
  98.     text.setAttribute("value",certs[x].commonName);
  99.     box.appendChild(text);
  100.   }
  101.  
  102.   setText("impact",impact);
  103.   window.sizeToContent();
  104. }
  105.  
  106. function doOK()
  107. {
  108.   for(var i=0;i<certs.length;i++)
  109.   {
  110.     certdb.deleteCertificate(certs[i]);
  111.   }
  112.   window.close();
  113. }
  114.  
  115. function doHelp()
  116. {
  117.    openHelp(helpUrl);
  118. }
  119.